import {apiRequest, baseRequest, oauthRequest} from "@/utils/HttpRequest";


export async function findByListDataSource() {
  //SwaggerResources


  return apiRequest<API.SwaggerResource[]>("swagger-resources").then(res => {

    return res.map(item => ({
      label: item.name,
      value: item.location
    }))

  })


}

export async function findByListDataDocumentSource(url: string) {
  //SwaggerResources


  return apiRequest<API.SwaggerDoc>(
    "docs?url=" + url, {
      method: "GET",
      data: {url: url}
    })


}


export async function findByListObjectDataDocumentSource(url: string, params?: any, method: string = 'GET',) {
  //SwaggerResources
  url = url.replace("/", "")
  console.log(params)
  return baseRequest<API.DataType<any>>(
    url, {
      method: method, params: {...params}
    })

}
export  async function editTable(params:object){
  return oauthRequest<API.BaseResult>("devise/editTable",{
    method: "POST",
    data: params
  })
}
